#include <vector>
using namespace std;
// 贪心解法
int maxProfit(vector<int> &prices) {
  vector<int> profit(prices.size(), 0);
  for (int i = 1; i < prices.size(); ++i) {
    profit[i] = prices[i] - prices[i - 1];
  }
  int maxProfit = 0;
  for (int i = 0; i < prices.size(); i++) {
    if (profit[i] > 0)
      maxProfit += profit[i];
  }
  return maxProfit;
}